#include <stdio.h>

int searchmin(int B[],int n){
    int size;
    if (n%2==0){size=n/2;}
    else{size=(n+1)/2;}
    
    int min[size];
    
    for (int i=0;i<=(n-1)/2;i++){
        min[i]=(B[i]<=B[n-i-1]?B[i]:B[n-i-1]);    
    }
    if (size==1)return min[0];
    return searchmin(min,size);
}

int searchmax(int B[],int n){
    int size;
    if (n%2==0){size=n/2;}
    else{size=(n+1)/2;}
    
    int max[size];
    
    for (int i=0;i<=(n-1)/2;i++){
        max[i]=(B[i]>=B[n-i-1]?B[i]:B[n-i-1]);    
    }
    if (size==1)return max[0];
    return searchmax(max,size);
}

void search(int A[], int n){
    int size;
    if (n%2==0){size=n/2;}
    else{size=(n+1)/2;}

    int min[size];
    int max[size];
    for (int i=0;i<=(n-1)/2;i++){
        min[i]=(A[i]<=A[n-i-1]?A[i]:A[n-i-1]);
        max[i]=(A[i]>=A[n-i-1]?A[i]:A[n-i-1]);
    }
    int minnumber=searchmin(min,size);
    int maxnumber=searchmax(max,size);
    printf("The min number is %d.\nThe max number is %d\n",minnumber,maxnumber);
    
}